import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;

public class DBUtil {
    private static volatile DataSource dataSource = null;
    private DBUtil(){

    }
    public static DataSource getDateSource() {
        if(dataSource == null){
            synchronized (DBUtil.class){
                if(dataSource == null) {
                    dataSource = new MysqlDataSource();
                    ((MysqlDataSource) dataSource).setURL("jdbc:mysql://127.0.0.1:3306/java?characterEncoding=utf8&useSSL=false");
                    ((MysqlDataSource) dataSource).setUser("root");
                    ((MysqlDataSource) dataSource).setPassword("284013");
                    //((MysqlDataSource)dataSource).setPassword("");
                }
            }
        }
        return dataSource;
    }
}
